問題描述
PostgreSQL:單個表的 pg_dump (PostgreSQL: pg_dump for a single table)
我是 PostgreSQL 的初學者並使用以下方法進行備份:
sudo ‑u postgres pg_dumpall > /~/postgreBackup.SQL
工作正常!現在我想備份一個表“TableName”。在方案“SchemeName”中 並嘗試了
sudo ‑u postgres pg_dump ‑‑table "SchemaName"."TableName" > /~/Dummy.SQL
pg_dump: 沒有找到匹配的表
如何讓它工作?
參考解法
方法 1:
When you have case sensitive table and schema name you have to do the proper quoting of a table name. The below command should work fine as I have successfully executed it at my end.
Please make sure you are using the correct case sensitive name of database, schema and table in this command.
./pg_dump ‑‑dbname="myDatabase" ‑‑host=localhost ‑‑port=5432 ‑‑username=postgres ‑‑table='"MyScheme"."TableName 01"' ‑‑file=Dummy
OR
./pg_dump ‑‑dbname="myDatabase" ‑‑host=localhost ‑‑port=5432 ‑‑username=postgres ‑‑table='"MyScheme"."TableName 01"' > ~/Dummy.SQL
Disclosure: I work for EnterpriseDB (EDB)
(by StOMicha、Amjad Shahzad)